<?php

add_action('admin_menu', 'setup_theme_admin_menu');

function setup_theme_admin_menu() {
  add_menu_page(
      'College Guide Theme Settings',
      'College Guide Settings',
      'manage_options',
      'college_guide_settings',
      'college_guide_settings_page'
  );
}

function college_guide_settings_page() { 
?>
  <style type="text/css">
      <?php include('settings.css'); ?>
  </style>
  <div>
    <?php screen_icon('themes'); ?>
    <h2>College Guide Theme Settings</h2>
    
    <form method="POST" action="">
    <input type="hidden" name="update_settings" value="Y" />
    <table class="form-table">
    <tr>
      <th><label for="blog_name">Name of the college blog:</label></th>
      <td>
	<input type="text" name="blog_name"
	      value="<?php print get_option("blog_name");?>"
	      size="40" />
      </td>
    </tr>
        <tr>
      <th><label for="background_color">Background color:</label></th>
      <td>
	<input type="text" name="background_color"
	      value="<?php print get_option("background_color");?>"
	      size="40" />
      </td>
    </tr>
        <tr>
      <th><label for="box_color">Foreground color:</label></th>
      <td>
	<input type="text" name="box_color"
	      value="<?php print get_option("box_color");?>"
	      size="40" />
      </td>
    </tr>
    </table>
    <p>
      <input type="submit" value="Save settings" class="button-primary"/>
    </p>
    </form>
    
  </div>
<?php
if (isset($_POST["update_settings"])) {
  // save data
    $blog_name = esc_attr($_POST["blog_name"]);
    update_option("blog_name", $blog_name);
    $background_color = esc_attr($_POST["background_color"]);
    update_option("background_color", $background_color);
    $box_color = esc_attr($_POST["box_color"]);
    update_option("box_color", $box_color);
  ?>
    <div id="message" class="updated">Settings saved</div>
  <?php }
}

?>